<?php
class BuyAction extends Action{
	
	public function _initialize(){
		if(!isset($_SESSION["pid"])){
			if(!isset($_COOKIE["pid"])){
				$this->redirect("partner/Public/login");
			}else{
				$_SESSION["pid"] = $_COOKIE["pid"];
				$_SESSION["name"] = M("Partner")->where("pid = ".$_SESSION["pid"])->find()["name"];
			}
		}
	
		
	}
	//显示套餐页面
	public function showPackList(){
		
	}
	
	//显示购买页面
	public function showBuyPage(){
		
	}
	//购买
	public function BuyIt(){
		
	}
	
	
	public function addClick(){
		$pid = $_SESSION["pid"];
		$num = 1;//$_POST["num"];
		if (M("Partner")->where("pid = $pid")->setInc("click_num",$num)){
			$data=array("massage"=>"增加成功","url"=>"partner/Advert/index");
			$this->redirect("partner/Public/redirectHtml",$data);
			exit;
		}else{
			$data=array("massage"=>"增加失败","url"=>"partner/Advert/index");
			$this->redirect("partner/Public/redirectHtml",$data);
			exit;
		}
	}
	
	public function addDay(){
		$pid = $_SESSION["pid"];
		$num = 1;//$_POST["num"];
		if (M("Partner")->where("pid = $pid")->setInc("click_day",$num)){
			$data=array("massage"=>"增加成功","url"=>"partner/Advert/index");
			$this->redirect("partner/Public/redirectHtml",$data);
			exit;
		}else{
			$data=array("massage"=>"增加失败","url"=>"partner/Advert/index");
			$this->redirect("partner/Public/redirectHtml",$data);
			exit;
		}
	}
	
}